<?php

/**
 * Created by PhpStorm.
 * User: 4399-0661
 * Date: 15-5-13
 * Time: 下午7:53
 */
class LibRunTime
{
    static $START = 0;
    static $STOP = 0;

    /**
     * 获取当前的时间 包含毫秒的那种
     * @return float
     */
    static public function getMicrotime()
    {
        list($usec, $sec) = explode(" ", microtime());
        return (float)$usec + (float)$sec;
    }

    /**
     * 设置运行开始时间
     */
    static public function setStart()
    {
        self::$START = self::getMicrotime();
    }

    /**
     * 设置运行结束时间
     */
    static public function setStop()
    {
        self::$STOP = self::getMicrotime();
    }

    /**
     * 得到程序的运行时间
     * @return int
     */
    static public function getRunTime()
    {
        $time = self::$STOP - self::$START;
        $time = $time * 1000;
        return $time;
    }

} 